package cfg.mpsc;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


public class EdgesPath {
	
	
	private List<IEdge> path = new ArrayList<IEdge>();

	public void add(IEdge e) {
		path.add(e);
	}
	
	
	public String toString(){
		return Arrays.toString(path.toArray());
	}
	
	
	/**
	 * Creates a list of all possible tuples in this path
	 * */
	public List<List<IEdge>> mpscTuples(){
		List<List<IEdge>> tuples = new ArrayList<List<IEdge>>();
		int maxGap = path.size();
		
		for(int gap=1;gap<=maxGap;++gap){//gera varios gaps
			for(int points=1;points<=path.size();++points){	//gera varios valores de p
				for(int startIdx=-path.size()+1-maxGap*points;startIdx<path.size();++startIdx){	//gera varios subcaminhos
					//System.out.println("gap:"+gap+" points:"+points+" startIdx:"+startIdx);
					if(startIdx+points*gap<=0){
						//System.out.println("infactivel");
					} else {
						List<IEdge> tuple = MPSC.generate(path,gap,points,startIdx);
						//System.out.println(tuple);
						if(!MPSC.contains(tuples,tuple) && MPSC.isValid(tuple)){
							tuples.add(tuple);
						}
						
					}
				}
			}
		}
		return tuples;
	}
	
	public List<List<IEdge>> mpscTuples(int gap, int points){
		List<List<IEdge>> tuples = new ArrayList<List<IEdge>>();
		int maxGap = path.size();
		for(int startIdx=-path.size()+1-maxGap*points;startIdx<path.size();++startIdx){	//gera varios subcaminhos
			//System.out.println("gap:"+gap+" points:"+points+" startIdx:"+startIdx);
			if(startIdx+points*gap<=0){
				//System.out.println("infactivel");
			} else {
				List<IEdge> tuple = MPSC.generate(path,gap,points,startIdx);
				//System.out.println(tuple);
				if(!MPSC.contains(tuples,tuple) && MPSC.isValid(tuple)){
					tuples.add(tuple);
				}
			}
		}
		return tuples;
	}
	

}
